package com.example.hj.service;

import com.example.hj.service.impl.FeignServiceFallbackImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by HuangJian on 2020/7/22.
 * 指定fallback 定义容错的处理类，当调用远程接口失败或超时时，会调用对应接口的容错逻辑，
 * fallback指定的类必须实现@FeignClient标记的接口
 */
@FeignClient(value = "eureka-client", fallback = FeignServiceFallbackImpl.class)  //开启Feign客户端，注解值是微服务的serviceId
public interface FeignService {

    //对应要调用的微服务控制层请求方法，方法签名必须完全一致包括注解
    @RequestMapping("/user/{id}")
    String getUser(@PathVariable("id") Long id);
}
